import React, { Component } from 'react'
import { action } from 'mobx'
import {observer, inject} from 'mobx-react'

@inject('cartStore', 'productsStore')
@observer
class CartComp extends Component {

  render() {
    const {cartStore, productsStore} = this.props
    return (
      <div>
        <ul>
          {
            cartStore.items.map((item) => {
              return (
                <li key={item.id}>
                  {item.title} ---- {item.price} ---- {item.quantity}
                </li>
              )
            })
          }
        </ul>
        {/* {JSON.stringify(cartStore.items)} */}
        <div>
          总价： {cartStore.totalPrice}
        </div>
      </div>
    )
  }
}

export default CartComp
